//只用选择结构解决多个数求模27的问题
#include<stdio.h>
#include<math.h>
int main()
{
    int a,b,c,d,e;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	
    if(a%27==0)
    {printf("YES\n");}
    else printf("NO\n");
 
    if(b%27==0)
    {printf("YES\n");}
    else printf("NO\n");
    
     if(c%27==0)
    {printf("YES\n");}
    else printf("NO\n");
    
     if(d%27==0)
    {printf("YES\n");}
    else printf("NO\n");
    
     if(e%27==0)
    {printf("YES\n");}
    else printf("NO\n");

	
	return 0;

 } 
